package com.joker.aigc.chat.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joker.aigc.chat.domain.dto.ContactQueryCriteria;
import com.joker.aigc.chat.domain.vo.ContactVo;
import com.joker.aigc.chat.service.ContactService;
import com.joker.aigc.domain.entity.R;
import com.joker.aigc.utils.RequestHolder;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/api/1.0/contact")
@Validated
@Tag(name = "contact", description = "消息管理相关接口")
public class ContactController {


    final ContactService contactService;

    /**
     * @param request
     * @return
     */
    @PostMapping("/public/contact/page")
    @Operation(summary = "公开的 用于用户的会话列表")
    public R<Page<ContactVo>> getContactPage(@Valid @RequestBody ContactQueryCriteria request) {
        Long uid = RequestHolder.get().getUid();
        return R.ok(contactService.getRoomPage(uid, request));
    }

    @GetMapping("/public/contact/detail")
    @Operation(summary = "会话详情")
    public R<ContactVo> getContactDetail(@NotNull(message = "") Long roomId) {
        Long uid = RequestHolder.get().getUid();
        return R.ok(contactService.getContactDetail(uid, roomId));
    }

    @GetMapping("/public/contact/detail/friend")
    @Operation(summary = "会话详情")
    public R<ContactVo> getContactDetailByFriend(@NotNull(message = "好友id") Long friendId) {
        Long uid = RequestHolder.get().getUid();
        return R.ok(contactService.getContactDetailByFriend(uid, friendId));
    }




}
